import functools
import os

from loguru import logger


def logging():
    path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    file_path = os.path.join(path, "logs", "{time:YYYY-MM-DD}.log")
    logger.add(file_path,
               rotation="50MB",  # 自动循环过超过500M的文件
               # rotation="12:00",  # 每天12点自动创建
               # rotation="1 week",  # 文件超过一周自动创建
               encoding="utf-8",  # 写文件的编码格式为utf-8
               retention="30 days",  # 最长保留30天，自动删除
               compression="zip",  # 文件保留成zip格式
               enqueue=True,  # 支持异步写入
               )


from loguru import logger


# def logTitle(info):
#     def message(fun):
#         @functools.wraps(fun)
#         def output(*args, **kwargs):
#             logger.info(info)
#             fun(*args, **kwargs)
#
#         return output
#
#     return message
#
#
# class Tag(object):
#     def __init__(self, tag):
#         self.tag = tag
#
#     def __call__(self, func):
#         def wrapped(*args, **kwargs):
#             logger.info(self.tag)
#             func(*args, **kwargs)
#
#         return wrapped


# @Tag('b0090909')
# def hello(name):
#     return 'hello %s' % name
#
#
# hello("hhhh")
